package com.auroramanito.uaa.validation;

import com.auroramanito.uaa.annotation.PasswordMatch;
import com.auroramanito.uaa.domain.dto.UserDTO;
import lombok.val;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class PasswordMatchValidator implements ConstraintValidator<PasswordMatch, UserDTO> {

    @Override
    public void initialize(PasswordMatch constraintAnnotation) {

    }

    @Override
    public boolean isValid(UserDTO userDTO, ConstraintValidatorContext context) {
        val result = userDTO.getPassword().equals(userDTO.getMatchingPassword());
        return result;
    }

}
